package lzzy;

public class GenericMethodDemo {
    public static void main(String[] args) {
        Integer[] integers = {1, 2, 3, 4, 5};
        String[] strings = {"London", "Paris", "New York", "Austin"};
        GenericMethodDemo.print(integers);
        GenericMethodDemo.print(strings);

        // 新增一个double数组调用
        Double[] doubles = {2.3,5.6,9.5};
        GenericMethodDemo.print(doubles);

        //新增一个学生类数组调用
        Student stu_1 = new Student("1","颜林廷","20200317081");
        Student stu_2 = new Student("2","yyy","123456");
        Student stu_3 = new Student("3","ytt","741852963");
        Student[] student = {stu_1,stu_2,stu_3};
        GenericMethodDemo.println(student);

    }

    public static <E> void print(E[] list) {
        for (int i = 0; i< list.length; i++)
            System.out.print(list[i] + " ");
        System.out.println();
    }

    public static <E> void println(E[] list) {
        for (int i = 0; i< list.length; i++)
            System.out.println(list[i] + " ");
        System.out.println();
    }
}
